% give bits of information for each neuron (row) across all patterns
% using a histogram with 'levels' bins.
% bits, or entopy = -sum over i p(i)*log2(p(i)).
function bits = bitsinfo(pattern,levels)

h=hist(pattern',levels);

if size(pattern,1)==1
    
    h=h';
end

h=bsxfun(@rdivide,h,sum(h)); % binary singleton expansion function. Allows single value per column!

log2h=log2(h);
log2h(log2h==-Inf)=0;

bits = -sum(h.*log2h);

